package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhAfterFactoryBalance;
import com.ruoyi.zsyh.service.IZsyhAfterFactoryBalanceService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 售后厂家账户变动Controller
 * 
 * @author yuexl
 * @date 2022-08-22
 */
@Controller
@RequestMapping("/zsyh/afterFactoryBalance")
public class ZsyhAfterFactoryBalanceController extends BaseController
{
    private String prefix = "zsyh/afterFactoryBalance";

    @Autowired
    private IZsyhAfterFactoryBalanceService zsyhAfterFactoryBalanceService;

    @RequiresPermissions("zsyh:afterFactoryBalance:view")
    @GetMapping()
    public String afterFactoryBalance()
    {
        return prefix + "/afterFactoryBalance";
    }

    /**
     * 查询售后厂家账户变动列表
     */
    @RequiresPermissions("zsyh:afterFactoryBalance:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhAfterFactoryBalance zsyhAfterFactoryBalance)
    {
        startPage();
        List<ZsyhAfterFactoryBalance> list = zsyhAfterFactoryBalanceService.selectZsyhAfterFactoryBalanceList(zsyhAfterFactoryBalance);
        return getDataTable(list);
    }

    /**
     * 导出售后厂家账户变动列表
     */
    @RequiresPermissions("zsyh:afterFactoryBalance:export")
    @Log(title = "售后厂家账户变动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhAfterFactoryBalance zsyhAfterFactoryBalance)
    {
        List<ZsyhAfterFactoryBalance> list = zsyhAfterFactoryBalanceService.selectZsyhAfterFactoryBalanceList(zsyhAfterFactoryBalance);
        ExcelUtil<ZsyhAfterFactoryBalance> util = new ExcelUtil<ZsyhAfterFactoryBalance>(ZsyhAfterFactoryBalance.class);
        return util.exportExcel(list, "售后厂家账户变动数据");
    }

    /**
     * 新增售后厂家账户变动
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存售后厂家账户变动
     */
    @RequiresPermissions("zsyh:afterFactoryBalance:add")
    @Log(title = "售后厂家账户变动", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhAfterFactoryBalance zsyhAfterFactoryBalance)
    {
        return toAjax(zsyhAfterFactoryBalanceService.insertZsyhAfterFactoryBalance(zsyhAfterFactoryBalance));
    }

    /**
     * 修改售后厂家账户变动
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ZsyhAfterFactoryBalance zsyhAfterFactoryBalance = zsyhAfterFactoryBalanceService.selectZsyhAfterFactoryBalanceById(id);
        mmap.put("zsyhAfterFactoryBalance", zsyhAfterFactoryBalance);
        return prefix + "/edit";
    }

    /**
     * 修改保存售后厂家账户变动
     */
    @RequiresPermissions("zsyh:afterFactoryBalance:edit")
    @Log(title = "售后厂家账户变动", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhAfterFactoryBalance zsyhAfterFactoryBalance)
    {
        return toAjax(zsyhAfterFactoryBalanceService.updateZsyhAfterFactoryBalance(zsyhAfterFactoryBalance));
    }

    /**
     * 删除售后厂家账户变动
     */
    @RequiresPermissions("zsyh:afterFactoryBalance:remove")
    @Log(title = "售后厂家账户变动", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhAfterFactoryBalanceService.deleteZsyhAfterFactoryBalanceByIds(ids));
    }
}
